<template>
  <!-- 文章分类 -->
  <div class="category">
    <div class="main">
      <div class="header">
        <el-form :inline="true">
          <el-form-item label="标签名称">
            <el-input placeholder="请输入标签名称"></el-input>
          </el-form-item>
          <el-form-item label="状态">
            <el-select placeholder="请选择标签状态"></el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary">查询</el-button>
            <el-button>重置</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="success" @click="dialogFrom = true">
              <el-icon><Plus /></el-icon>
              <span>新增标签</span>
            </el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="danger">
              <el-icon><Minus /></el-icon>
              <span>批量删除</span>
            </el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="body" v-if="tags.length > 0">
        <el-table :data="tags">
          <el-table-column type="selection"></el-table-column>
          <el-table-column label="标签名称">
            <template #scope>
              <el-tag>标签</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="关联文章数量"></el-table-column>
          <el-table-column label="关联动态数量"></el-table-column>
          <el-table-column label="关联项目数量"></el-table-column>
          <el-table-column label="状态"></el-table-column>
          <el-table-column label="创建时间"></el-table-column>
          <el-table-column label="修改时间"></el-table-column>
          <el-table-column>
            <template #default="scope">
              <el-button type="danger" :text="true">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-empty v-else></el-empty>
      <div class="page">
        <el-pagination
          v-model:current-page="findTag.page"
          v-model:page-size="findTag.pageSize"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @current-change="handelPage"
          @size-change="handelPageSize"
        ></el-pagination>
      </div>
      <el-dialog v-model="dialogFrom" width="500" style="padding: 20px">
        <el-form>
          <el-form-item label="标签名称">
            <el-input placeholder="请输入标签名称"></el-input>
          </el-form-item>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button @click="dialogFrom = false">Cancel</el-button>
            <el-button type="primary" @click="addCategory">OK</el-button>
          </div>
        </template>
      </el-dialog>
    </div>
  </div>
</template>

<script setup>
import { Plus, Minus } from '@element-plus/icons-vue'
import { ElMessageBox } from 'element-plus'
import { ref } from 'vue'

const tags = ref([{}])

const total = ref(5)
const findTag = ref({
  page: 1,
  pageSize: 5,
  categoryName: '',
  status: null,
})

const dialogFrom = ref(false)

const addCategory = () => {
  dialogFrom.value = false
}

const handelPage = (page) => {
  console.log(page)
}
const handelPageSize = (pageSize) => {
  console.log(pageSize)
}
</script>

<style lang="scss" scoped>
.category {
  padding: 15px;
  min-height: 100vh;
  background-color: #f3f4f5;

  .main {
    padding: 20px;
    min-height: 100vh;
    background-color: #fff;
    border-radius: 7px;

    .header {
      :deep(.el-select__wrapper) {
        width: 150px;
      }
    }

    .page {
      margin-top: 20px;
      display: flex;
      justify-content: center;
    }
  }
}
</style>